package com.flyqiu.common.clazz;

import java.lang.reflect.Field;
import java.util.Objects;
import java.util.function.Function;

@FunctionalInterface
public interface FlyQiuFieldFilter {
    boolean filter(Field field, Class<?> clazz);

    default FlyQiuFieldFilter andThen(FlyQiuFieldFilter after) {
        Objects.requireNonNull(after);
        return (Field field, Class<?> clazz) -> {
            boolean currentResult = this.filter(field, clazz);
            if (!currentResult) {
                return false; // 如果当前过滤器返回 false，则不再执行后续过滤器
            }
            return after.filter(field, clazz); // 执行后续过滤器
        };
    }
}
